import Vue from 'vue'
import Router from 'vue-router'
/*第一种：导入hello组件*/
// import hello from '../components/demo/hello.vue'

/*第二种：导入hello组件*/
import hello from '@/components/demo/hello'
/*第一种：导入hello01组件*/
import hello01 from '../components/demo/hello01.vue'

import testAjax from '../components/demo/testAjax.vue'

import error from '../components/demo/erroe.vue'
import testLogin from "../components/demo/testLogin.vue"
import testIndex from "../components/demo/testIndex.vue"
import testUpdatePwd from '../components/demo/testUpdatePwd.vue'
import testUpdatePwd2 from '../components/demo/testUpdatePwd2.vue'
import login from "../components/exam/login.vue"
import index from '../components/exam/index.vue'
import welcome from '../components/exam/welcome.vue'
import questionManager from '../components/exam/questionManager.vue'
import paperCreate from '../components/exam/paperCreate.vue'
import ex from '../components/exam/exam.vue'
import paperCreate2 from '../components/exam/paperCreate2.vue'
import ex2 from '../components/exam/exam2.vue'
Vue.use(Router)

export default new Router({
  mode:"history",/* 切换到history模式 */
  routes: [
    {
      path: '/',/*斜杠表示默认地址*/
      name: 'hello',/*组件名称，保持名称唯一性*/
      component: hello/*引入组件的别名*/
    },
    {
      path:'/hello01',
      name:"hello01",
      component:hello01
    },
    {
      path:'/testAjax',
      name:"testAjax",
      component:testAjax
    },
    {
      path:'*',
      name:"error",
      component:error
    },
    {
      path:'/testLogin',
      name:"testLoginr",
      component:testLogin
    },
    {
      path:'/testIndex',
      name:"testIndex",
      component:testIndex
    },
    {
      path:'/testUpdatePwd',
      name:"testUpdatePwd",
      component:testUpdatePwd
    },
    {
      path:'/testUpdatePwd2',
      name:"testUpdatePwd2",
      component:testUpdatePwd2
    },
    {
    path:'/ex',
    meta:{"isLogin":true},
    name:"ex",
    component:ex
    },
    {
    path:'/ex2',
    meta:{"isLogin":true},
    name:"ex2",
    component:ex2
    },
    {
      path:'/login',
      name:"login",
      component:login
    },
    {
      path:'/index',
      name:"index",
      meta:{"isLogin":true},//定义页面是否需要拦截,需要登录后才能访问这个页面
      redirect:"/welcome",//默认打开index页面，子路由视图指向的地址
      component:index,
      children:[//子路由配置
       {
          path:'/welcome',
          name:"welcome",
          meta:{"isLogin":true},
          component:welcome
        },
        {
          path:'questionManager',
          meta:{"isLogin":true},
          name:"questionManager",
          component:questionManager
        },
        {
          path:'paperCreate',
          meta:{"isLogin":true},
          name:"paperCreate",
          component:paperCreate
        },
        {
          path:'paperCreate2',
          meta:{"isLogin":true},
          name:"paperCreate2",
          component:paperCreate2
        }

      ],
    }

  ]
})
